package com.shudes.game;

import java.util.*;

public class Deck extends CardCollection {

	protected int index;
	
	public Deck() {
		super(52);
		populateDeck();
	}
	
	private void populateDeck() {
		index=0;
		for(Suit s : Suit.getAll()) {
			for(Rank r : Rank.getAll()) { 
				this.add(new Card(r,s));
			}
		}
	}
	
	public void remove(Card c) { 
		this.cards.remove(c); 
	}
	
	public void remove(CardCollection c) { 
		for(Card card : c.getCards()) { 
			remove(card); 
		}
	}
	
	public void shuffle() { 
		Collections.shuffle(cards); 
	}
	
	public Card deal() {
		return cards.get(index++); 
	}
	
	public CardCollection deal(int count) { 
		CardCollection c = new CardCollection(count); 
		for(int i=0;i<count;i++) { 
			c.add(deal()); 
		}
		
		return c;
	}
	
}
